package org.demo;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author yexi
 */
@Mapper
public interface UserStruct {
    UserStruct INSTANCE = Mappers.getMapper(UserStruct.class);

    @Mapping(source = "birthday", target = "birthday", dateFormat = "yyyy-MM-dd")
    @Mapping(target = "regDate", expression = "java(user.getRegDate() == null? null : new SimpleDateFormat(\"yyyy-MM-dd\").format(user.getRegDate()))")
    @Mapping(source = "userExtend.regSource", target = "registerSource")
    @Mapping(source = "userExtend.favorite", target = "favorite")
    @Mapping(target = "memo", ignore = true)
    UserVO changeToUserVO(User user);

    List<UserVO> changeToUserVOs(List<User> userList);
}